package be.novelfaces.webdriver;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

public abstract class BaseComponent extends BaseElement {
	
	private final By compIdBy;

	public BaseComponent(By compId) {
		compIdBy = compId;
	}
	
	public boolean isRendered() {
		return this.isRendered(getComponentBy());
	}

	public By getComponentBy() {
		return compIdBy;
	}
	
	public WebElement getComponent() {
		return getWebDriver().findElement(compIdBy);
	}
	
	private boolean isRendered(By by) {
		try {
			getWebDriver().findElement(by);
			return true;
		} catch (Exception e) {
			return false;
		}
	}

}
